<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: pink;
        }
    </style>
</head>

<body>
    <div>123</div>
    <script>
        var div = document.querySelector('div');
        div.onclick = function (event) {  //event是事件对象，写带侦听函数里面，只有onclick事件才会存在
            //event是系统自动创建的，不需要传递参数，ie678不兼容
            console.log(event);
            console.log(window.event);  //表示ie678兼容的写法
            e = e || windows.event;  //兼容性的处理

        }
        div.addEventListener('click', function (event) {
            console.log(event); //可以用e代替  
        })

    </script>
</body>

</html>